package org.vs.controller;

import org.springframework.web.bind.annotation.*;
import org.vs.annotation.Login;
import org.vs.domain.dto.LoginDTO;
import org.vs.result.RestResult;
import org.vs.result.RestResultBuilder;
import org.vs.service.SysUserService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户管理接口
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private SysUserService userService;

    @PostMapping("/login")
    public RestResult login(@RequestBody LoginDTO loginDTO) {
        return userService.login(loginDTO);
    }

    @GetMapping("/info")
    public RestResult info(@RequestParam("token") String token) {
        return userService.info(token);
    }

    @PostMapping("/logout")
    public RestResult logout() {
        return new RestResultBuilder().success();
    }

    @Login
    @GetMapping("/all")
    public RestResult all() {
        return userService.all();
    }
}
